package com.woniuxy.ticketuser.controller;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.woniuxy.ticketcommon.entity.ResponseResult;
import com.woniuxy.ticketuser.entity.User;
import com.woniuxy.ticketuser.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/add")
    public String add(){
        return "user-add";
    }

    /**
     * 修改用户积分
     * @param id            用户id
     * @param integration   增加/减少的积分
     * @return              操作结果
     */
    @PutMapping("/updateUserIntegration")
    public ResponseResult updateUserIntegration(@RequestParam("id") Integer id,@RequestParam("integration") Integer integration){
        User user = userService.getById(id);
        user.setIntegration(user.getIntegration()+integration);
        userService.updateById(user);
        log.info("更新积分");

        return ResponseResult.SUCCESS;
    }

}
